<?php

namespace App\Http\Controllers\Agency;

use App\Http\Controllers\Controller;
use App\Services\SeasService;
use hg\apidoc\annotation as Apidoc;
use Illuminate\Http\Request;

/**
 * 公海管理
 * @Apidoc\Group("crm")
 */
class SeasController extends Controller
{
    /**
     * @Apidoc\Title ("公海列表")
     * @Apidoc\Url("/agency/seasList")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("page",type="int",require=true,desc="页数")
     * @Apidoc\Param("pageSize",type="int",require=true,desc="条数")
     * @Apidoc\Param("id",type="int",require=false,desc="用户id")
     * @Apidoc\Param("username",type="string",require=false,desc="用户昵称")
     * @Apidoc\Param("realname",type="string",require=false,desc="用户姓名")
     * @Apidoc\Param("mobile",type="string",require=false,desc="用户手机号")
     * @Apidoc\Param("gender",type="int",require=false,desc="用户性别1：男；2：女；3：未知")
     * @Apidoc\Param("maxHeight",type="int",require=false,desc="用户最大身高")
     * @Apidoc\Param("minHeight",type="int",require=false,desc="用户最小身高")
     * @Apidoc\Param("maxAge",type="int",require=false,desc="用户最大年龄")
     * @Apidoc\Param("minAge",type="int",require=false,desc="用户最小年龄")
     * @Apidoc\Param("maxWeight",type="int",require=false,desc="用户最大体重")
     * @Apidoc\Param("minWeight",type="int",require=false,desc="用户最小体重")
     * @Apidoc\Param("status",type="string",require=false,desc="用户资料状态wait：待审核；pass：通过；refuse：未通过")
     * @Apidoc\Param("education",type="int",require=false,desc="用户学历")
     * @Apidoc\Param("marry",type="int",require=false,desc="用户婚况")
     * @Apidoc\Param("house",type="int",require=false,desc="用户购房情况")
     * @Apidoc\Param("car",type="int",require=false,desc="用户购车情况")
     * @Apidoc\Param("salary",type="int",require=false,desc="用户年收入")
     * @Apidoc\Param("vvipid",type="int",require=false,desc="用户会员等级")
     * @Apidoc\Param("province",type="int",require=false,desc="用户现居省code")
     * @Apidoc\Param("city",type="int",require=false,desc="用户现居市code")
     * @Apidoc\Param("area",type="int",require=false,desc="用户现居区code")
     * @Apidoc\Param("reside_province",type="int",require=false,desc="用户户籍省code")
     * @Apidoc\Param("reside_city",type="int",require=false,desc="用户户籍市code")
     * @Apidoc\Param("reside_area",type="int",require=false,desc="用户户籍区code")
     * @Apidoc\Param("istop",type="string",require=false,desc="是否置顶Y已置顶；N未置顶")
     * @Apidoc\Param("job",type="int",require=false,desc="用户工作")
     * @Apidoc\Param("ishidden",type="int",require=false,desc="用户信息状态1：公开相亲；2：私密相亲；3：已脱单")
     * @Apidoc\Param("isfreeze",type="int",require=false,desc="是否冻结'Y'是,'N'否")
     * @Apidoc\Param("oldbelongid",type="int",require=false,desc="用户原归属人")
     * @Apidoc\Param("tgid",type="int",require=false,desc="用户推广人")
     * @Apidoc\Param("source",type="int",require=false,desc="用户来源")
     * @Apidoc\Param("followStartTime",type="int",require=false,desc="用户跟进开始时间")
     * @Apidoc\Param("followEndTime",type="int",require=false,desc="用户跟进结束时间")
     * @Apidoc\Param("startTime",type="string",require=false,desc="用户创建开始时间")
     * @Apidoc\Param("endTime",type="string",require=false,desc="用户创建结束时间")
     * @Apidoc\Param("loginStartTime",type="string",require=false,desc="用户最近登录开始时间")
     * @Apidoc\Param("loginEndTime",type="string",require=false,desc="用户最近登录结束时间")
     * @Apidoc\Param("dropStartTime",type="string",require=false,desc="坠海开始时间")
     * @Apidoc\Param("dropEndTime",type="string",require=false,desc="坠海结束时间")
     * @Apidoc\Param("type",type="int",require=false,desc="0全部、1线上、2线下、")
     * @Apidoc\Param("order",type="string",require=true,desc="排序字段created_at：注册时间；followtime：跟进时间；logintime：登录时间；intotime：坠海时间")
     * @Apidoc\Param("sort",type="string",require=true,desc="顺序：asc顺序；desc倒序")
     * @Apidoc\Returned("id",type="int",require=false,desc="用户id"),
     * @Apidoc\Returned("sn",type="string",require=false,desc="用户编号"),
     * @Apidoc\Returned("username",type="string",require=false,desc="用户昵称"),
     * @Apidoc\Returned("realname",type="string",require=false,desc="用户姓名"),
     * @Apidoc\Returned("age",type="int",require=false,desc="用户年龄"),
     * @Apidoc\Returned("height",type="int",require=false,desc="用户身高"),
     * @Apidoc\Returned("avatar",type="string",require=false,desc="用户头像"),
     * @Apidoc\Returned("gender",type="int",require=false,desc="用户性别1：男；2：女；3：未知"),
     * @Apidoc\Returned("birthday",type="string",require=false,desc="用户生日"),
     * @Apidoc\Returned("national",type="int",require=false,desc="用户民族"),
     * @Apidoc\Returned("marry",type="int",require=false,desc="用户婚况"),
     * @Apidoc\Returned("education",type="int",require=false,desc="用户学历"),
     * @Apidoc\Returned("job",type="int",require=false,desc="用户工作"),
     * @Apidoc\Returned("salary",type="int",require=false,desc="用户年收入"),
     * @Apidoc\Returned("mobile",type="string",require=false,desc="用户手机号"),
     * @Apidoc\Returned("belongprovince",type="string",require=false,desc="用户手机号归属地省"),
     * @Apidoc\Returned("belongcity",type="string",require=false,desc="用户手机号归属地市"),
     * @Apidoc\Returned("weixin",type="string",require=false,desc="用户微信"),
     * @Apidoc\Returned("province",type="int",require=false,desc="用户现居省code"),
     * @Apidoc\Returned("province",type="int",require=false,desc="用户现居省code"),
     * @Apidoc\Returned("province_name",type="string",require=false,desc="用户现居省"),
     * @Apidoc\Returned("city",type="int",require=false,desc="用户现居市code"),
     * @Apidoc\Returned("city_name",type="string",require=false,desc="用户现居市"),
     * @Apidoc\Returned("area",type="int",require=false,desc="用户现居区code"),
     * @Apidoc\Returned("area_name",type="string",require=false,desc="用户现居区"),
     * @Apidoc\Returned("logintime",type="string",require=false,desc="登录时间"),
     * @Apidoc\Returned("type",type="int",require=false,desc="用户类型，1线上2线下"),
     * @Apidoc\Returned("smoking",type="int",require=false,desc="用户吸烟情况"),
     * @Apidoc\Returned("drinking",type="int",require=false,desc="用户喝酒情况"),
     * @Apidoc\Returned("logintime",type="string",require=false,desc="最近登录时间"),
     * @Apidoc\Returned("intention",type="int",require=false,desc="用户意向"),
     * @Apidoc\Returned("created_at",type="string",require=false,desc="用户注册时间"),
     * @Apidoc\Returned("status",type="string",require=false,desc="用户状态"),
     * @Apidoc\Returned("belongid",type="int",require=false,desc="用户归属人id"),
     * @Apidoc\Returned("tgid",type="int",require=false,desc="用户推广人id"),
     * @Apidoc\Returned("makerid",type="int",require=false,desc="用户路录人id"),
     * @Apidoc\Returned("serviceid",type="int",require=false,desc="用户服务人id"),
     * @Apidoc\Returned("vipid",type="int",require=false,desc="VIP等级id"),
     * @Apidoc\Returned("istop",type="int",require=false,desc="是否置顶0：未置顶；1：已置顶；2已过期；"),
     * @Apidoc\Returned("ishidden",type="int",require=false,desc="信息状态，1：公开相亲；2：私密相亲；3：已脱单；"),
     * @Apidoc\Returned("ispay",type="int",require=false,desc="审核费用Y已付费；N未付费"),
     * @Apidoc\Returned("followtime",type="string",require=false,desc="上次跟进时间"),
     * @Apidoc\Returned("source",type="int",require=false,desc="用户来源"),
     * @Apidoc\Returned("remark",type="string",require=false,desc="备注"),
     * @Apidoc\Returned("interest",type="array",require=false,desc="用户兴趣爱好"),
     * @Apidoc\Returned("personality",type="array",require=false,desc="用户性格"),
     * @Apidoc\Returned("intro",type="string",require=false,desc="用户自我介绍"),
     * @Apidoc\Returned("evaluate",type="string",require=false,desc="红娘评价"),
     * @Apidoc\Returned("genderText",type="string",require=false,desc="字段注释"),
     * @Apidoc\Returned("marryText",type="string",require=false,desc="字段注释"),
     * @Apidoc\Returned("educationText",type="string",require=false,desc="字段注释"),
     * @Apidoc\Returned("jobText",type="string",require=false,desc="字段注释"),
     * @Apidoc\Returned("salaryText",type="string",require=false,desc="字段注释"),
     * @Apidoc\Returned("houseText",type="string",require=false,desc="字段注释"),
     * @Apidoc\Returned("carText",type="string",require=false,desc="字段注释"),
     * @Apidoc\Returned("typeText",type="string",require=false,desc="字段注释"),
     * @Apidoc\Returned("intentionText",type="string",require=false,desc="字段注释"),
     * @Apidoc\Returned("statusText",type="string",require=false,desc="字段注释"),
     * @Apidoc\Returned("belongText",type="string",require=false,desc="字段注释"),
     * @Apidoc\Returned("tgText",type="string",require=false,desc="字段注释"),
     * @Apidoc\Returned("makerText",type="string",require=false,desc="字段注释"),
     * @Apidoc\Returned("istopText",type="string",require=false,desc="字段注释"),
     * @Apidoc\Returned("serviceText",type="string",require=false,desc="字段注释"),
     * @Apidoc\Returned("ishiddenText",type="string",require=false,desc="字段注释"),
     * @Apidoc\Returned("ispayText",type="string",require=false,desc="字段注释"),
     * @Apidoc\Returned("sourceText",type="string",require=false,desc="字段注释"),
     * @Apidoc\Returned("bloodText",type="string",require=false,desc="字段注释"),
     * @Apidoc\Returned("companytypeText",type="string",require=false,desc="字段注释"),
     * @Apidoc\Returned("drinkingText",type="string",require=false,desc="字段注释"),
     * @Apidoc\Returned("smokingText",type="string",require=false,desc="字段注释"),
     * @Apidoc\Returned("zodiacText",type="string",require=false,desc="字段注释"),
     * @Apidoc\Returned("constellationText",type="string",require=false,desc="字段注释"),
     * @Apidoc\Returned("nationalText",type="string",require=false,desc="字段注释"),
     * @Apidoc\Returned("childText",type="string",require=false,desc="字段注释"),
     * @Apidoc\Returned("interestText",type="string",require=false,desc="字段注释"),
     * @Apidoc\Returned("personalityText",type="string",require=false,desc="字段注释"),
     *
     */
    public function seasList(SeasService $seasService , Request $request)
    {
        $params = $request->input();
        $params['uid'] = $this->getUid();
        $params['aid'] = $this->getAid();
        $result = $seasService->getList($params);
        return $this->responseSuccess($result);
    }

    /**
     * @Apidoc\Title ("公海列表-批量领取")
     * @Apidoc\Url("/agency/seasDraw")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("ids",type="string",require=true,desc="1,2,3....")
     * @Apidoc\Param("remark",type="string",require=false,desc="备注")
     * @Apidoc\Returned("true",type="bool",desc="保存状态")
     *
     */
    public function seasDraw(SeasService $seasService , Request $request)
    {
        $params = $request->input();
        $params['uid'] = $this->getUid();
        $params['uname'] = $this->getUname();
        $params['aid'] = $this->getAid();
        $result = $seasService->seasDraw($params);
        if($result)
            return $this->responseSuccess($result);
        else
            return $this->responseError("领取失败，请联系管理员！");
    }

    /**
     * @Apidoc\Title ("公海列表-表头信息")
     * @Apidoc\Url("/agency/seasHeadList")
     * @Apidoc\Method("GET")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Returned("key",type="string",desc="表头key值")
     * @Apidoc\Returned("value",type="array",desc="是否显示：true显示；false隐藏")
     *
     */
    public function seasHeadList(SeasService $seasService , Request $request)
    {
        $params = $request->input();
        $params['uid'] = $this->getUid();
        $params['aid'] = $this->getAid();
        $params['position'] = 4;   //公海客户
        $result = $seasService->getHeadList($params);
        return $this->responseSuccess($result);
    }

    /**
     * @Apidoc\Title ("公海列表-保存表头信息")
     * @Apidoc\Url("/agency/seasHeadUpdate")
     * @Apidoc\Method("POST")
     * @Apidoc\Header("Authorization", type="string",require=true, desc="Bearer + accessToken")
     * @Apidoc\Param("params",type="array",require=true,desc="表头json数组")
     * @Apidoc\Returned("true",type="bool",desc="保存状态")
     *
     */

    public function seasHeadUpdate(SeasService $seasService , Request $request)
    {
        $params = $request->input();
        $params['uid'] = $this->getUid();
        $params['aid'] = $this->getAid();
        $params['position'] = 4;   //全部用户
        $result = $seasService->seasHeadUpdate($params);
        if($result)
            return $this->responseSuccess($result);
        else
            return $this->responseError(400);
    }
}
